import 'package:yurun_smartmerchants/models/tally_detail_entity.dart';

tallyDetailEntityFromJson(TallyDetailEntity data, Map<String, dynamic> json) {
	if (json['total'] != null) {
		data.total = json['total']?.toDouble();
	}
	if (json['products'] != null) {
		data.products = new List<TallyDetailProduct>();
		(json['products'] as List).forEach((v) {
			data.products.add(new TallyDetailProduct().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> tallyDetailEntityToJson(TallyDetailEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['total'] = entity.total;
	if (entity.products != null) {
		data['products'] =  entity.products.map((v) => v.toJson()).toList();
	}
	return data;
}

tallyDetailProductFromJson(TallyDetailProduct data, Map<String, dynamic> json) {
	if (json['modifiedTime'] != null) {
		data.modifiedTime = json['modifiedTime']?.toString();
	}
	if (json['quantity'] != null) {
		data.quantity = json['quantity']?.toDouble();
	}
	if (json['categoryiiName'] != null) {
		data.categoryiiName = json['categoryiiName'];
	}
	if (json['consumerId'] != null) {
		data.consumerId = json['consumerId']?.toInt();
	}
	if (json['packageContainer'] != null) {
		data.packageContainer = json['packageContainer']?.toString();
	}
	if (json['packageUnit'] != null) {
		data.packageUnit = json['packageUnit']?.toString();
	}
	if (json['creatorId'] != null) {
		data.creatorId = json['creatorId'];
	}
	if (json['modifierId'] != null) {
		data.modifierId = json['modifierId'];
	}
	if (json['categoryiiId'] != null) {
		data.categoryiiId = json['categoryiiId']?.toInt();
	}
	if (json['title'] != null) {
		data.title = json['title']?.toString();
	}
	if (json['inventory'] != null) {
		data.inventory = json['inventory']?.toDouble();
	}
	if (json['categoryiId'] != null) {
		data.categoryiId = json['categoryiId']?.toInt();
	}
	if (json['url'] != null) {
		data.url = json['url']?.toString();
	}
	if (json['marketId'] != null) {
		data.marketId = json['marketId']?.toInt();
	}
	if (json['number'] != null) {
		data.number = json['number']?.toString();
	}
	if (json['categoryiiiName'] != null) {
		data.categoryiiiName = json['categoryiiiName']?.toString();
	}
	if (json['customizedCategoryId'] != null) {
		data.customizedCategoryId = json['customizedCategoryId']?.toInt();
	}
	if (json['price'] != null) {
		data.price = json['price'];
	}
	if (json['tallyQuantity'] != null) {
		data.tallyQuantity = json['tallyQuantity'];
	}
	if (json['categoryiName'] != null) {
		data.categoryiName = json['categoryiName']?.toString();
	}
	if (json['createdTime'] != null) {
		data.createdTime = json['createdTime'];
	}
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	if (json['categoryiiiId'] != null) {
		data.categoryiiiId = json['categoryiiiId']?.toInt();
	}
	if (json['status'] != null) {
		data.status = json['status']?.toInt();
	}
	return data;
}

Map<String, dynamic> tallyDetailProductToJson(TallyDetailProduct entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['modifiedTime'] = entity.modifiedTime;
	data['quantity'] = entity.quantity;
	data['categoryiiName'] = entity.categoryiiName;
	data['consumerId'] = entity.consumerId;
	data['packageContainer'] = entity.packageContainer;
	data['packageUnit'] = entity.packageUnit;
	data['creatorId'] = entity.creatorId;
	data['modifierId'] = entity.modifierId;
	data['categoryiiId'] = entity.categoryiiId;
	data['title'] = entity.title;
	data['inventory'] = entity.inventory;
	data['categoryiId'] = entity.categoryiId;
	data['url'] = entity.url;
	data['marketId'] = entity.marketId;
	data['number'] = entity.number;
	data['categoryiiiName'] = entity.categoryiiiName;
	data['customizedCategoryId'] = entity.customizedCategoryId;
	data['price'] = entity.price;
	data['tallyQuantity'] = entity.tallyQuantity;
	data['categoryiName'] = entity.categoryiName;
	data['createdTime'] = entity.createdTime;
	data['id'] = entity.id;
	data['categoryiiiId'] = entity.categoryiiiId;
	data['status'] = entity.status;
	return data;
}